<script>
export default {
	onLaunch: function() {
		// #ifdef APP-PLUS
		plus.navigator.closeSplashscreen();
		plus.screen.lockOrientation('portrait-primary');
		// #endif
		// console.log('App Launch');
	},
	onShow: function() {
		uni.getSystemInfo({
			success: e => {
				let statusBar = 0;
				let customBar = 0;

				// #ifdef MP
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + 45;
				if (e.platform === 'android') {
					customBar = e.statusBarHeight + 50;
				}
				// #endif

				// #ifdef MP-WEIXIN
				statusBar = e.statusBarHeight;
				// @ts-ignore
				const custom = wx.getMenuButtonBoundingClientRect();
				customBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif

				// #ifdef MP-ALIPAY
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + e.titleBarHeight;
				// #endif

				// #ifdef APP-PLUS
				// console.log('app-plus', e)
				statusBar = e.statusBarHeight;
				customBar = e.statusBarHeight + 45;
				// #endif

				// #ifdef H5
				statusBar = 0;
				customBar = e.statusBarHeight + 45;
				// #endif
				this.$store.dispatch('system/set_status_bar', statusBar);
				this.$store.dispatch('system/set_custom_bar', customBar);
				this.$store.dispatch('system/set_system_info', e);
			}
		});
	},
	onHide: function() {
		// console.log('App Hide');
	},
	// #ifndef H5
	methods: {
		runtimeQuit() {
			uni.showModal({
				title: '提示',
				content: '您确定要退出应用吗？',
				success: function(res) {
					if (res.confirm) {
						plus.runtime.quit();
					}
				}
			});
		}
	}
	// #endif
};
</script>

<style lang="scss">
/*每个页面公共css */
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import 'uview-ui/index.scss';
</style>
